home *** CD-ROM | disk | FTP | other *** search
- /*
- File: InkDrone.c
-
- Contains: QuickDraw GX to PostScript conversion code.
- File contains the ink drone. This used to be in ShapeParts
- but was extracted for the purpose of segmentation
-
- Version: Technology: Quickdraw GX 1.1.x
-
- Copyright: © 1992-1997 by Apple Computer, Inc., all rights reserved.
- */
-
- #include "GXToPSBuildConfig.h"
- #include <GXGraphics.h>
- #include "GXGraphicsPriv.h"
- #include <GXEnvironment.h>
- #include "GXToPostScript.h"
- #include "IOUtilities.h"
- #include "RDUtil.h"
- #include "FontHandler.h"
- #include "PublicPostScriptIE.h"
- #include "private.h"
- #include "PSIEResources.h"
- #include "GXErrors.h"
- #include "ShapeUtilities.h"
-
- #ifdef resumeLabel
- #undef resumeLabel
- #endif
- #define resumeLabel(exception)
-
- //<FF>
- /************************************
- InkDrone:
-
- Convert the gx graphics Ink into PostScript or
- use the PostScript synonym on the Ink.
-
- Routine converts the color into the specified
- shape color space and then dispatches to the
- appropriate color primitive.
-
- It is assumed that transfer modes (other than or-mode)
- are pre-resolved so They are ignored by the Ink drone.
- (That is until there is a version of PostScript that
- supports Transfer Modes)
-
- The Ink drone will also check for the Ink synonym and
- use it if it exists.
-
- hIEGlobals: the Imaging Engine globals
- theInk: The ink to translate.
- theShape: The shape it came from.
-
- *************************************/
- OSErr _InkDrone(TIEGlobalsHdl hIEGlobals, gxInk theInk)
- {
- OSErr status = noErr;
- TIEGlobalsPtr pGlobals;
- TRDParams *pRDParams;
- gxColor theColor;
- gxColorSpace theSpace;
- short orMode;
- gxColorProfile theProfile;
- long nSyn, i;
- gxTag psSynonym;
- gxTag halftoneTag;
- TGstate *pGstate;
-
-
- pGlobals = *hIEGlobals;
- pRDParams = pGlobals->pRDParams;
-
- nSyn = GXGetInkTags(theInk, gxPostScriptTag, 1, gxSelectToEnd, nil);
-
- if (nSyn > 0) {
-
- nrequire(status = EndProcSetDict(pRDParams), failed_Ink);
- nrequire(status = RDFlushBuffer(pRDParams->rdMap), failed_Ink); /* OutputTag calls buffer data message dirctly*/
-
- for (i = 1; i <= nSyn; ++i) {
-
- GXGetInkTags(theInk, gxPostScriptTag, i, 1, &psSynonym);
- nrequire(status = OutputTag(hIEGlobals, psSynonym), failed_Ink);
-
- }//end for
-
- nrequire(status = BeginProcSetDict(pRDParams), failed_Ink);
-
- (*hIEGlobals)->ieStateFlags |= eInkOutOfDate;
-
- } else {
-
- /** First deal with any potential halftone tags. **/
-
- if (GXGetInkTags(theInk, gxFormatHalftoneTag, 1, gxSelectToEnd, nil))
- GXGetInkTags(theInk, gxFormatHalftoneTag, 1, 1, &halftoneTag);
- else
- halftoneTag = nil;
-
- pGlobals = *hIEGlobals;
- pGstate = &(pGlobals->gStateNest[pGlobals->gStateDepth]);
-
- if ( (pGstate->halftoneTag != halftoneTag) ) {
-
- if (halftoneTag != nil) {
-
- gxFormatHalftoneInfo *halftoneInfo;
-
- GXLockTag(halftoneTag);
- halftoneInfo = (gxFormatHalftoneInfo*)GXGetTagStructure(halftoneTag, nil);
-
- status = HalftonePrimitive(hIEGlobals, halftoneInfo);
- GXUnlockTag(halftoneTag);
-
- nrequire(status, failed_Halftone);
-
- } else {
-
- pRDParams->resIndex = kSetDefaultScreen;
- nrequire(status = RDResPrintf(pRDParams), failed_Halftone);
-
- }//end if
-
- /** Make sure graphics state owns the halftone **/
- pGstate = &((*hIEGlobals)->gStateNest[pGlobals->gStateDepth]);
-
- if (pGstate->halftoneTag != nil)
- GXDisposeTag(pGstate->halftoneTag);
-
- pGstate->halftoneTag = halftoneTag;
- if (halftoneTag != nil)
- GXCloneTag(halftoneTag);
-
- }//end if
-
- /** We'll need the color **/
-
- GXGetInkColor(theInk, &theColor);
-
- /** Output the orModeness of the ink for bitmap shapes and shapes with 1-bit bitmap patterns **/
-
- orMode = TestInkModeOr(theInk);
-
- pGlobals = *hIEGlobals;
- if ( (orMode != pGlobals->orMode) || (pGlobals->ieStateFlags & eTmodeOutOfDate) ) {
-
- pGlobals->orMode = orMode;
-
- pRDParams->resIndex = kSetOrMode;
- nrequire(status = RDResPrintf(pRDParams, orMode), failed_Mode);
-
- }//end if
-
- /** Now deal with the color **/
-
- pGlobals = *hIEGlobals;
-
- if (pGlobals->params.renderOptions & gxUseLevel2ColorOption) {
-
- status = Level2ColorPrimitive(hIEGlobals, &theColor);
- ncheck(status);
-
- } else {
-
- theSpace = pGlobals->params.devCSpace;
- theProfile = pGlobals->params.devCProfile;
-
- GXConvertColor(&theColor, theSpace, nil, theProfile);
- nrequire(status = GXGetGraphicsError(nil), failed_ConvertColor);
-
- switch (theSpace) {
-
- case gxRGBSpace:
- status = RGBColorPrimitive(hIEGlobals, &(theColor.element.rgb));
- ncheck(status);
- break;
-
- case gxGraySpace:
- status = GrayColorPrimitive(hIEGlobals, theColor.element.gray);
- ncheck(status);
- break;
-
- case gxCMYKSpace:
- status = CMYKColorPrimitive(hIEGlobals, &(theColor.element.cmyk));
- ncheck(status);
- break;
-
- default:
- #if DEBUGLEVEL > 0
- dprintf(notrace, "Requested color space (%d) Invalid", theSpace);
- #endif
- status = colorSpace_out_of_range;
- break;
-
- }//end switch
-
- }//end if
-
- (*hIEGlobals)->ieStateFlags &= ~eInkOutOfDate;
-
- }//end if
-
- failed_Mode:
- failed_ConvertColor:
- failed_Halftone:
- failed_Ink:
- return(status);
-
- }//InkDrone
-
-